home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993 October: Windmill on DISC / ADC Developer CD (1993-10) (''Windmill On DISC'')_iso / Dev.CD Oct 93.iso / Utilities / Installer v3.4.3 / Examples - Installer 3.4 / Action Atom Samples / Lock File Installer AA Sample / SetLockBit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-15  |  2.2 KB  |  78 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2.  *
  3.  *    Apple Macintosh Developer Technical Support
  4.  *
  5.  *  Installer 3.4 sample: Action Atoms
  6.  *
  7.  *    File:        SetLockBit.c -    c Source
  8.  *
  9.  *    by:            Rich Kubota
  10.  *  updated for use with Installer 3.4, 9/1/92
  11.  *
  12.  *    Copyright © 1990-1992 Apple Computer, Inc.
  13.  *    All rights reserved.
  14.  *
  15.  *    Purpose: Sample to demonstrate setting the file lock bit.  This action
  16.  *        atom code resource must be called through a post installation action
  17.  *        atom.  In the selector field, pass in the name of the target 'infs'
  18.  *        resource id.  The code resource gets the resource, converts the partial
  19.  *        path name field to a pascal string, then calls, SetFLock.  A result of 
  20.  *        true is always returned so as not to abort the installation.
  21.  *        
  22.  *        This action atom is designed for use by Installer 3.3 and 3.4 only as it
  23.  *        returns a longint result instead of a Boolean
  24.  *
  25.  *    Note: If a target file is locked, then the Installer will report an error
  26.  *        to the user alerting them to the fact that the target file must be
  27.  *        manually unlocked.
  28.  *----------------------------------------------------------------------------*/
  29.  
  30. #if 0
  31.  
  32. C -r -b  SetLockBit.c
  33. Link -ra =resPurgeable -t rsrc -c RSED -rt infn=10000 ∂
  34.     -m SETLOCKBIT -sg SetLockBit ∂
  35.     SetLockBit.c.o ∂
  36.     "{Libraries}"Interface.o ∂
  37.     -o SetLockBit.rsrc
  38.  
  39. #endif
  40.  
  41. #include <Types.h>
  42. #include <Resources.h>
  43. #include <Files.h>
  44. #include "ActionAtomIntf.h"
  45.  
  46. /* define record structure of 'infs' resource so that we can access the target file path */
  47.  
  48. struct infsRec {
  49.     long    fileType;
  50.     long    creator;
  51.     long    creationDate;
  52.     short    fileSpecFlags;
  53.     Str255    pathName;
  54. };
  55.  
  56. typedef struct infsRec infsRec;
  57. typedef infsRec **infsHdl;
  58.  
  59. /* protoypes */
  60. void    makePStr(char *fm, char *to);
  61.  
  62.  
  63. pascal long    SETLOCKBIT(AAPBRecPtr myAAPBPtr)
  64. {
  65.     OSErr    err;
  66.     infsHdl    resH;
  67.     
  68.     if (myAAPBPtr->whichStage == after) {    // make sure that this is the right stage
  69.                                             // and that the atom is not being called
  70.                                             // as a result of a cancel operation
  71.     
  72.         resH = (infsHdl)GetResource('infs', myAAPBPtr->aaRefCon);
  73.         if (resH)
  74.             err = SetFLock((*resH)->pathName, myAAPBPtr->targetVRefNum);
  75.     }
  76.     return noErr;    // return noErr unless it is necessary to report otherwise.
  77. }
  78.